package com.openlogic.j.utils;

import java.io.IOException;

import com.openlogic.j.exception.OpenDecisionHttpException;

/**
 * @ClassName: DecisionUtils
 * @Description: 工具类
 * @author weiyongpeng
 * @date 2025年2月24日 上午9:00:58
 */
public class DecisionUtils {

	public static RuntimeException toException(retrofit2.Response<?> response) throws IOException {
		return new OpenDecisionHttpException(response.code(), response.errorBody().string());
	}

	public static RuntimeException toException(okhttp3.Response response) throws IOException {
		return new OpenDecisionHttpException(response.code(), response.body().string());
	}

	public static <T> T getOrDefault(T value, T defaultValue) {
		return value != null ? value : defaultValue;
	}
}
